from django_filters import FilterSet
from django_filters import rest_framework as filters
from userweb.models import *


class AccountFilter(FilterSet):
    # 如果要支持模糊的筛选，必须重写筛选的条件的字段
    name = filters.CharFilter(field_name='name', lookup_expr='icontains')
    mobile = filters.CharFilter(field_name='mobile', lookup_expr='icontains')
    class Meta:
        model = Account
        fields = ('loginid', 'name', 'mobile')


class RolesFilter(FilterSet):
    min_order = filters.NumberFilter(field_name="order", lookup_expr="gt") #gte【>=】 gt【>】
    max_order = filters.NumberFilter(field_name="order", lookup_expr="lt")  # lte【<=】 lt【>】

    class Meta:
        model = Roles
        fields = ('name', 'min_order', 'max_order')



